<!-- 登录 -->
<template>
    <div class="login">
        <div class="title">登  录</div>
        <nut-textinput  v-model="addForm.uid" placeholder="请输入用户名" style="margin-bottom: 20px;" @keyup.enter.native="handleLogin" />
        <nut-textinput  v-model="addForm.password" placeholder="请输入密码" type="password" @keyup.enter.native="handleLogin" />
        <div class="tip">
            <router-link to="/register">没有账号？前往注册></router-link>
        </div>
        <div class="login-btn" @click="handleLogin">登  录</div>
    </div>
</template>

<script>

import { API_Login } from "@/api/system"

export default {
    data() {
        return {
            addForm: {
                uid: '',
                password: ''
            }
        }
    },
    created() {

    },
    mounted() {

    },
    computed: {

    },
    methods: {
        // 登录
        handleLogin() {
            if(!this.addForm.uid) {
                this.$toast.fail('请输入用户名！');
                return;
            }
            if(!this.addForm.password) {
                this.$toast.fail('请输入密码！');
                return;
            }
            API_Login(this.addForm).then(res => {
                if(res.data.code === 0) {
                    localStorage.setItem('user', res.data.result);
                    this.$toast.success('登录成功');
                    this.$router.push('/');
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>

@import "~@/assets/style/helper.scss";

.login {
    width: 100%;
    height: 100%;
    padding: 150px 20px 0;
    .title {
        font-size: 28px;
        font-weight: bold;
        color: $color-highlight;
        margin-bottom: 50px;
    }
    .nut-textinput {
         input {
            border: 1px solid $color-highlight;
        }
    }
    .tip {
        margin-top: 10px;
        color: $color-highlight;
        text-align: right;
        a {
            font-size: 12px;
        }
    }
    .login-btn {
        font-size: 16px;
        color: $color-bgc;
        padding: 13px 24px;
        margin: 20px 10px;
        border: none;
        border-radius: 10px;
        background-color: $color-highlight;
    }
}

</style>